//
//  LoadMoreView.m
//  TongKuan
//
//  Created by Beny on 13-5-22.
//  Copyright (c) 2013年 TongKuan. All rights reserved.
//

#import "LoadMoreView.h"
#import "KSLanguageManager.h"

@interface LoadMoreView ()


@end

@implementation LoadMoreView

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        self.activityIndicatorView = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(110, 15, 23, 20)];
        self.activityIndicatorView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
        [self.activityIndicatorView startAnimating];
        [self addSubview:self.activityIndicatorView];

        self.textLabel = [[UILabel alloc] initWithFrame:CGRectMake(140, 17, 120, 15)];
        self.textLabel.textColor = [UIColor lightGrayColor];
        self.textLabel.backgroundColor = [UIColor clearColor];
        self.textLabel.font = [UIFont systemFontOfSize:14];
        [self addSubview:self.textLabel];
        [self setLabelText:IMTNewCarLocalizedString(@"Loading")];
    }
    return self;
}

- (void)setLabelText:(NSString *)text {
    self.textLabel.text = text;
    [self.textLabel sizeToFit];
    self.textLabel.center = CGPointMake(self.frame.size.width / 2.0, self.frame.size.height / 2.0);
    self.activityIndicatorView.frame = CGRectMake(self.textLabel.frame.origin.x - self.activityIndicatorView.frame.size.width, self.activityIndicatorView.frame.origin.y, self.activityIndicatorView.frame.size.width, self.activityIndicatorView.frame.size.height);
}

//设置加载更多完成状态
- (void)setFinishedState:(BOOL)state {
    if (state) {
        [self setLabelText:IMTNewCarLocalizedString(@"NoMore")];
        [self.activityIndicatorView stopAnimating];
    } else {
        [self setLabelText:IMTNewCarLocalizedString(@"Loading")];
        [self.activityIndicatorView startAnimating];
    }

}

@end
